<template>
	<view class="fixedTop">
		<view class="top-nav-box">
			<view class="nav-back" @click="navBack()">
				<view class="image-wrapper"><image src="@/static/img/black-back.png" mode="aspectFit"></image></view>
			</view>
			<view class="nav-txt flex1">余额</view>
			<!-- <slot></slot> -->
		</view>
		<view class="item-main">
<!--			<view class="main-img"><image src="@/static/img/moreMoney.png" mode=""></image></view>-->
      <view class="countmoney">基本账户</view>
			<view class="main-price">￥{{user.money}}</view>
      <view class="main-content">
        <view class="main-content-money">
          <view class="main-content-money-title">可用余额</view>
          <view class="main-content-getmoney">{{user.use_money}}</view>
        </view>
        <view class="main-content-money">
          <view class="main-content-money-title">不可用余额</view>
          <view class="main-content-getmoney">
            <view class="nodomoney">{{user.no_use_money}}</view>
            <view style="position: relative">
              <image  src="@/static/img/gantanhao.png" mode="" style="width: 30rpx;height: 30rpx;margin-top: 10rpx" @click="showTooltip()"></image>
             <view v-if="showTooltips" class="tooltips">待结算余额涉及的订单，在服务完成或服务解除后即可结算，并转到可用余额里。</view>
            </view>
          </view>
        </view>
      </view>
			<view class="" v-for="(item, index) in data" :key="index">
				<view class="main-add" :class="index == current ? 'active' : ''" @click="changePay(index)">{{ item }}</view>
				<!-- <view class="main-add main-up">提现</view> -->
			</view>
      <view class="footer">
        <view class="nav-right" @click="goNext()"><text style="margin: 0 auto;font-size: 26rpx;">余额明细</text></view>
        <view class="nav-right"><text style="margin: 0 auto;font-size: 26rpx;">提现管理</text></view>
        <view class="nav-right"><text style="margin: 0 auto;font-size: 26rpx;">提现明细</text></view>
      </view>
		</view>
	</view>
</template>
<script>
export default {
	data() {
		return {
			data: ['充值', '提现'],
			current: 0, //当前选择支付方式
			user:'',
      showTooltips:false

		};
	},

	onLoad() {
		this.init();
    this.gettopColor()
	},
	onShow() {
		this.init();
		console.log("onshow")
    this.gettopColor()
	},
	methods: {
    showTooltip(){
      this.showTooltips = true
      setTimeout(()=>{
        this.showTooltips = false
      },4000)
    },
    //判断顶部颜色
    gettopColor(){
      const nav = navigator.userAgent;
      if (nav.indexOf('Android') > -1 || nav.indexOf('Adr') > -1) {
        phone.setStatusBarColor("#ffffff")
      } else if (!!nav.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
        this.$bridge.callhandler('backgroundColorChange', {topColor:'#ffffff',bottomColor:"#ffffff"}, res => {});
      }
    },
		async init() {
			let formData = {
				token: uni.getStorageSync('token')
			};
			let res = await this.$api('index.user', formData);
			this.user = res.data.user;
		},
		navBack() {
			uni.navigateBack({
				delta: 1
			});
		},
		changePay(index) {
			this.current = index;
			if (index == 1) {
        // this.replace('/pages/client/user/withdraw')
			 uni.showToast({
				title: '功能开发中',
				icon: 'none'
			});	 
			/* uni.navigateTo({
					url: '../client/user/withdraw'
				}); */
			}else if(index==0){
				uni.navigateTo({
					url: './addMoney'
				});
        // this.replace('/pages/moreMoney/addMoney')
			}
		},
		goNext() {
			
			//return;
      this.jump('/pages/moreMoney/DeatilMoney')
			// uni.navigateTo({
			// 	url: './DeatilMoney'
			// });
		}
	}
};
</script>

<style lang="scss" scoped>
page {
	background-color: #ffffff;
}
.top-nav-box {
	background: #ffffff;
	color: #303133;
	text-align: center;
	position: relative;
	height: 88rpx;
	line-height: 88rpx;
	font-size: 32rpx;
	display: flex;
	width: 100%;
	// border-bottom: 2rpx solid #f2f2f2;
	.nav-txt {
		font-size: 32rpx;
	}
	.nav-back {
		width: 88rpx;
		height: 88rpx;
		position: absolute;
		top: 0;
		left: 0;
		.image-wrapper {
			margin-left: 14rpx;
			box-sizing: border-box;
			width: 34rpx;
			height: 34rpx;
			image {
				width: 100%;
				height: 100%;
			}
		}
	}
}
.item-main {
  .countmoney{
    text-align: center;
    margin-top:120rpx ;
    margin-bottom:20rpx ;
  }
  .main-content{
    margin-bottom: 120rpx;
    display: flex;
    align-items: flex-start;
    justify-content: space-around;
    .main-content-money{
      display: flex;
      justify-content: center;
      flex-direction: column;
      align-items: center;
      .main-content-getmoney{
        font-weight: bold;
        margin-top: 10rpx;
        display: flex;
        align-items: center;
        .nodomoney{
          margin-right: 10rpx;
        }
        .tooltips{
          position: absolute;
          padding: 20rpx;
          border-radius: 10rpx;
          top: -128rpx ;
          left: -68vw;
          font-weight: normal;
          color: #fff;
          background: rgba(0,0,0,0.8);
          width: 74vw;
          &::after{
            content: '';
            width: 0px;
            height: 0px;
            border-left: 22rpx solid transparent;
            border-right: 22rpx solid rgba(0, 0, 0, 0.8);
            border-bottom: 22rpx solid transparent;
            position: absolute;
            bottom: 0rpx;
            left: 68vw;
            transform: rotate(135deg);
          }
        }
      }
    }

  }
	.main-price {
		font-size: 80rpx;
		font-weight: bold;
		text-align: center;
		margin-bottom: 100rpx;
	}
	.main-add {
		width: 350rpx;
		height: 80rpx;
		background-color: #f2f2f2;
		//background-color: #70C226;
		color: #70c226;
		border-radius: 10rpx;
		margin: 0 auto 30rpx;
		text-align: center;
		font-size: 32rpx;
		font-weight: bold;
		line-height: 80rpx;
	}
	.active {
		background-color: #70c226;
		color: #ffffff;
	}
  .footer{
    position: fixed;
    bottom: 60rpx;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    .nav-right{
      width: 30%;
      text-align: center;
      color: #70c226;
      border-right: 2rpx solid #ccc;
      &:last-child{
        border: 0;
      }
    }
  }
}
</style>
